<?php
// +----------------------------------------------------------------------
// | 车钉钉 [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://www.twothink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: YagamiZN
// +----------------------------------------------------------------------
namespace app\admin\model;
use think\Model;

/**
 * 用户模型
 */

class Admin extends Model{
    protected $autoWriteTimestamp = true;
    
    protected $update = ['login_ip','login_time'];
    /**
     * 自动完成登陆ip
     */
    protected function setLoginIpAttr()
    {
        return request()->ip();
    }
    /**
     * 自动完成登陆时间
     */
    protected function setLoginTimeAttr()
    {
        return time();
    }
    /**
     * 自动完成密码加密
     */
    protected function setApwdAttr($value)
    {
        return md5($value);
    }
    /**
     * 角色获取器
     */
    public function getRoleAttr($value)
    {
        $status = [1=>'超级管理员',2=>'管理员'];
        return $status[$value];
        //return ['val' => $value, 'text' => $status[$value]];
    }

}
